<?php
session_start();
require("../includes/dbInfo.php");

$messageIDs  = $_POST['messageIDs'];
$delete      = $_POST['delete'] ;
$markUndread = $_POST['unread']; 

if( $messageIDs > 0 ) {

    // if we are deleting
    if( $delete != "" ) { 
        foreach ($messageIDs as $m) {
             mysql_query("UPDATE messages SET readStatus = 'DELETED' WHERE messageID = '$m' ")
            or die( mysql_error());
        }
    }
    // if we are marking as unread
    else { 
        foreach ($messageIDs as $u) {
            mysql_query("UPDATE messages SET readStatus = 'UNREAD' WHERE messageID = '$u' ") 
            or die (mysql_error());
        }
    }
}

// redirect away from post page.
header('location: inbox.php');
?>